﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Portal
{
    public static class JqueryEasyuiLinqExtension
    {
        public static JqEasyuiDataGrid<T> JqEasyuiDataGrid<T>(this IQueryable<T> queryable, int page = 1, int rows = 10) 
        {
            return new JqEasyuiDataGrid<T> { rows = queryable.Skip((page - 1) * rows).Take(rows).ToList(), total = queryable.Count() };
        }

        public static IList<JqEasyuiComboBox> JqEasyuiComboBox<T>(this IEnumerable<T> queryable, Expression<Func<T, JqEasyuiComboBox>> expression) 
        {
            return queryable.AsQueryable().Select(expression).ToList();
        }
    }
}
